#!/bin/bash
master=`mysql -h {{ master_host_ip }} -uroot -p{{ mysql_passwd }} -e "show master status;" 2>/dev/null | awk '{print $1}' | tail -1`
pos=`mysql -h {{ master_host_ip }} -uroot -p{{ mysql_passwd }} -e "show master status;" 2>/dev/null | awk '{print $2}' | tail -1`
mysql -u root -p{{ mysql_passwd }} -e "change master to master_host='{{ master_host_ip }}',master_user='repl',master_password='{{ mysql_passwd}}',master_log_file='$master',master_log_pos=$pos;"
mysql -u root -p{{ mysql_passwd }} -e "start slave;"
mysql -u root -p{{ mysql_passwd }} -e "show slave status\G;"
